import java.sql.SQLOutput;

class BankAccount{
    private double balance;
    public synchronized void deposit(double amount){
        balance += amount;
    }
    public synchronized void withdraw(double amount){
        if(balance>=amount){
            balance-=amount;
        }else {
            System.out.println("存款不足");
        }
    }
    public double getBalance(){
        return balance;
    }
}

public class bank {
    public static void main(String[] args) {
        BankAccount account = new BankAccount();
        Runnable task = ()->{
            account.deposit(100);
            account.withdraw(50);
            System.out.println("存款："+account.getBalance());
        };
        Thread t1 = new Thread(task);
        Thread t2 = new Thread(task);
        t1.start();
        t2.start();
    }
}
